/**
 * Created by Jessica on 17/2/17.
 */
"use strict";

var fs = require('fs');
var path = require('path');

var deleteFolderRecursive = function(dir) {

    var files = [];

    if( fs.existsSync(dir) ) {

        files = fs.readdirSync(dir);

        files.forEach(function(file,index){

            var curPath = path.join(dir, file);

            if(fs.statSync(curPath).isDirectory()) { // recurse

                deleteFolderRecursive(curPath);

            } else { // delete file

                fs.unlinkSync(curPath);

            }

        });

        fs.rmdirSync(dir);

    }

};

deleteFolderRecursive(path.join(__dirname, '../build'));